<%@page import="dao.impl.McTypeDAOImpl"%>
<%@page import="dao.impl.McDAOImpl"%>
<%@page import="bean.McTypeBean"%>
<%@page import="bean.McBean"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
	+ request.getServerName() + ":" + request.getServerPort()
	+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'mccrud.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

</head>

<body  style="margin-top: 30px">
	<div class="col-md-12">
		<%
			System.out.println(request.getParameter("oper"));
			String oper = request.getParameter("oper");
			McDAOImpl mcCRUDImpl = new McDAOImpl();
			List<McBean> allMcs = new ArrayList<McBean>();
			if (oper == null) {
				allMcs = mcCRUDImpl.selectMcList(request);
			} else if ("query".equals(oper)) {
				
				allMcs = mcCRUDImpl.queryMcs(request);
			}
		%>
		<div class="col-md-12" style="margin: 20px 20px">
			<form action="admin/adminMc.jsp?oper=query" method="post">
				<label>所属大类<select id="bigType" name="nmaxid"
					style="width: 85px; " onchange="fun1();">
						<option value="0">==请选择==</option>
						<%
							McTypeDAOImpl mcTypeCRUDImpl = new McTypeDAOImpl();
											List<McTypeBean> allBigTypes = mcTypeCRUDImpl.queryByNpid(0);
											for (McTypeBean typeBean : allBigTypes) {
						%>
						<option value="<%=typeBean.getNid()%>"><%=typeBean.getSname()%></option>
						<%
							}
						%>
				</select></label> <label>所属小类<select id="smallType" name="nminid"
					style="width: 83px; "></select></label> <label>关键字<input
					type="text" name="sname" style="width: 107px; "></label> <label>价格<input
					type="text" name="nminprice" style="width: 82px; ">至<input
					type="text" name="nmaxprice" style="width: 82px; "></label> <label><input
					type="submit" value="查询" style="width: 43px; "></label> <label><input
					type="button" value="添加商品"
					onclick="javascript:window.location.href='admin/addMc.jsp'"
					style="width: 85px; "></label>
			</form>
		</div>
		<div class="col-md-12">
			<form>
				<table border="1" class="table table-condensed">
					<tr>
						<td>图片</td>
						<td>名称</td>
						<td>单价</td>
						<td>是否缺货</td>
						<td>操作</td>
					</tr>

					<%
						System.out.println("长度" + allMcs.size());
						for (McBean mcBean : allMcs) {
					%>
					<tr>
						<td align="center"><a href="admin/addImg.jsp?nid=<%=mcBean.getNid()%>"><img src="image/<%=mcBean.getSimg()%>" width="30px" height="30px"></a></td>
						<td><%=mcBean.getSname()%></td>
						<td><%=mcBean.getNprice()%></td>
						<%
							if ("0".equals(mcBean.getSmctag())) {
						%>
						<td>缺货</td>
						<%
							} else {
						%>
						<td>否</td>
						<%
							}
						%>
						<td><a href="admin/updateMc.jsp?nid=<%=mcBean.getNid()%>">修改</a>&nbsp;&nbsp;<a
							href="OpeMcServlet?task=delete&nid=<%=mcBean.getNid()%>">删除</a></td>
					</tr>
					<%
						}
					%>
				</table>
			</form>
			<div>
				<%=(String)request.getAttribute("pageTool") %>
			</div>
		</div>
	</div>
</body>
</html>
